package com.lzt.admin.vo;

import com.lzt.admin.dto.user.UserDTO;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
@Getter
@Setter
public class UserDetailsVO  implements UserDetails {
    private UserDTO userDTO;
    public UserDetailsVO(){}
    public UserDetailsVO(UserDTO userDTO){
        this.userDTO = userDTO;
    }
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return getUserDTO().getPassword();
    }

    @Override
    public String getUsername() {
        return getUserDTO().getUsername();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return getUserDTO().getDisabled() == 0;
    }
}
